var express = require('express');
var router = express.Router();
var db = require('../config/db');
"use strict";
/* GET home page. */
router.post('/login_fun', function(req, res, next) {
	req.session.user = "nobody";
  var username = req.body.username;
  var password = req.body.password;
  try{
  var sql = "select * from manage where username = '"+username+"'and pwd ='"+password+"'";
  db.query(sql,function(err,rows){
      if(err){
        console.log(err.toString());
      }else {
      	if(rows.length!==0)
      	{
      		console.log("初始化后"+req.session.user);
        req.session.user = rows[0].id;
        console.log("赋值后"+req.session.user);
         res.send({mes:req.session.user});
       }
      	else
      	 res.send({mes:req.session.user});
        
      }
  });
  }
  catch(e)
  {
  	console.log(e.toString());
  }

});




module.exports = router;
